<?php
require_once( 'test_header.php');
require_once( CLASSMATE_ROOT.'/include/functions/mongo_connect.function.php' );
session::create();

class test_class_user_reg_process extends UnitTestCase{

	private $db_connect;
	private $email;

	 function setUp(){
	 	 
		 //建立数据库连接,并选择测试数据库
		 $this->db_connect = mongo_connect( '127.0.0.1' , 'test' );

		 //注册一个用户
		 $request = array( 'email' => rand() , 'password' => rand() );
		 $user_reg_process = new user_reg_process( $this->db_connect );
		 $reg_result = $user_reg_process->do_reg( $request );

		 $this->email = $request['email'];
	 }
	 function tearDown(){}

	 //测试用户成功注册的情况
	 function test_user_do_reg_success(){

	 	 //mock 用户已经登录
		 session::set( 'email' , $this->email );
		 $update = new update_user_profile_process( $this->db_connect , $this->email );

	 	 $request = array( 'email'=>'judasnow@gmail.com' , 'password'=>'123' );
	 	 $update->do_update( $request );
	 }	 
}

$test = new test_class_user_reg_process();
$test->run( new HtmlReporter() );
